home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / CUGUK / PROG_TOO / C027B.ZIP / JAS / PASS.C < prev    next >
Text File  |  1990-03-30  |  2KB  |  97 lines

  1.  
  2. /*
  3.  * Copyright (c) 1988 by Sozobon, Limited.  Author: Joseph M Treat
  4.  *
  5.  * Permission is granted to anyone to use this software for any purpose
  6.  * on any computer system, and to redistribute it freely, with the
  7.  * following restrictions:
  8.  * 1) No charge may be made other than reasonable charges for reproduction.
  9.  * 2) Modified versions must be clearly marked as such.
  10.  * 3) The authors are not responsible for any harmful consequences
  11.  *    of using this software, even if they result from defects in it.
  12.  */
  13.  
  14. #include "jas.h"
  15.  
  16. #define SCTALIGN 2
  17.  
  18. long dottxt = 0L, dotdat = 0L, dotbss = 0L, newdot = 0L;
  19. long uptxt, updat, upbss, txtsize, datsize, bsssize;
  20.  
  21. SYM dot;
  22.  
  23. aspass1()
  24. {
  25.     extern jmp_buf err_buf;
  26.     extern Optimize;
  27.  
  28.     dot.flags = TXT;
  29.     dot.value = newdot = 0L;
  30.  
  31.     yyinit();
  32.     if ( yyparse() ) {
  33.         longjmp( err_buf, 1 );
  34.     }
  35.  
  36.     chsegmt(TXT);
  37.  
  38.     if ( Optimize )
  39.         do_opt();
  40.  
  41.     txtsize = dottxt;
  42.     if ( uptxt = txtsize % SCTALIGN )
  43.         txtsize += (uptxt = SCTALIGN - uptxt);
  44.     datsize = dotdat;
  45.     if ( updat = datsize % SCTALIGN )
  46.         datsize += (updat = SCTALIGN - updat);
  47.     bsssize = dotbss;
  48.     if ( upbss = bsssize % SCTALIGN )
  49.         bsssize += (upbss = SCTALIGN - upbss);
  50.  
  51. /* don't adjust the segments ...
  52.     fixsymval( 0L, txtsize, DAT );
  53.     fixsymval( 0L, txtsize + datsize, BSS );
  54. ...  */
  55.  
  56.     bufhead();
  57.     symindex();
  58.     headers();
  59.  
  60.     dot.value = newdot = 0L;
  61.     translate( TXT, (int) uptxt );
  62.     translate( DAT, (int) updat );
  63.     dumpsym();
  64.     dumprel();
  65. }
  66.  
  67. chsegmt( segment )
  68.     unsigned short segment;
  69. {
  70.     switch ( dot.flags & SEGMT ) {
  71.     case TXT:
  72.         dottxt = newdot;
  73.         break;
  74.     case DAT:
  75.         dotdat = newdot;
  76.         break;
  77.     case BSS:
  78.         dotbss = newdot;
  79.         break;
  80.     }
  81.  
  82.     switch ( segment & SEGMT ) {
  83.     case TXT:
  84.         newdot = dottxt;
  85.         break;
  86.     case DAT:
  87.         newdot = dotdat;
  88.         break;
  89.     case BSS:
  90.         newdot = dotbss;
  91.         break;
  92.     }
  93.  
  94.     dot.flags = segment;
  95.     dot.value = newdot;
  96. }
  97.